package org.example.mapping;


import com.sun.jdi.LongType;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.example.config.Configuration;
import org.example.type.JdbcType;
import org.example.type.LongTypeHandler;
import org.example.type.TypeHandler;
import org.example.type.TypeHandlerRegistry;

@Builder
@AllArgsConstructor
@NoArgsConstructor
@Data
public class ParameterMapping {
    private Configuration configuration;
    private String property;
    private Class<?> javaType = Object.class;
    private JdbcType jdbcType;
    private String jdbcTypeName;
    private TypeHandler<?> typeHandler;

    public ParameterMapping(Configuration configuration, String property, Class<?> javaType) {
        this.configuration = configuration;
        this.property = property;
        this.javaType = javaType;
        resolveTypeHandler();
    }

    private void resolveTypeHandler() {
        this.typeHandler = configuration.getTypeHandler(this.javaType);
    }
}
